package com.four.hospital.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.four.common.utils.R;
import com.four.hospital.entity.Hospital;
import com.four.hospital.service.HospitalService;
import com.four.hospital.vo.HospitalVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:luojie
 * @Date: 2022/01/05/18:39
 * @Description
 */
@RestController
@RequestMapping("hospital/hospital")
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    /**
     * 医院分页模糊查
     * @param vo
     * @param page
     * @param size
     * @return
     */
    @PostMapping("/hospitalList")
    public R hospitalList(@RequestBody HospitalVo vo,
                          @RequestParam(value = "page",defaultValue = "1")Integer page,
                          @RequestParam(value = "size",defaultValue = "3")Integer size){
        IPage<Hospital> hospitalList=hospitalService.hospitalList(page,size,vo);
        return R.ok().put("hospitalList",hospitalList);
    }


    /**
     * 快速问诊
     * 输入医院名称查询医院信息
     * @param hosName
     * @return
     */
    @PostMapping("/getHospitalByName/{hosName}")
    public R getHospitalByName(@PathVariable("hosName")String hosName){
        List<Hospital> hospitalList=hospitalService.getHospitalByName(hosName);
        return R.ok().put("hospitalLis",hospitalList);
    }
}
